1 #region Using Statements
3 using System.Collections.Generic;
4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Content;
6 using Microsoft.Xna.Framework.Graphics;
7 using Microsoft.Xna.Framework.Input;
8 using Microsoft.Xna.Framework.Storage;
9 using Microsoft.Xna.Framework.GamerServices;
13 namespace SuperPolarity
16 /// This is the main type for your game
18 public class SuperPolarity : Game
20 public static GraphicsDeviceManager graphics;
21 SpriteBatch spriteBatch;
24 KeyboardState currentKeyboardState;
25 GamePadState currentGamePadState;
29 public SuperPolarity()
32 SuperPolarity.graphics = new GraphicsDeviceManager(this);
33 SuperPolarity.graphics.PreferMultiSampling = true;
34 Content.RootDirectory = "Content";
38 /// Allows the game to perform any initialization it needs to before starting to run.
39 /// This is where it can query for any required services and load any non-graphic
40 /// related content. Calling base.Initialize will enumerate through any components
41 /// and initialize them as well.
43 protected override void Initialize()
45 player = new MainShip();
51 /// LoadContent will be called once per game and is the place to load
52 /// all of your content.
54 protected override void LoadContent()
56 // Create a new SpriteBatch, which can be used to draw textures.
57 spriteBatch = new SpriteBatch(GraphicsDevice);
59 Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
61 player.Initialize(Content, Content.Load<Texture2D>("Graphics\\main-ship"), playerPosition);
65 /// UnloadContent will be called once per game and is the place to unload
68 protected override void UnloadContent()
70 // TODO: Unload any non ContentManager content here
74 /// Allows the game to run logic such as updating the world,
75 /// checking for collisions, gathering input, and playing audio.
77 /// <param name="gameTime">Provides a snapshot of timing values.</param>
78 protected override void Update(GameTime gameTime)
80 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
83 // TODO: Add your update logic here
85 InputController.UpdateInput();
86 player.Update(gameTime);
88 base.Update(gameTime);
92 /// This is called when the game should draw itself.
94 /// <param name="gameTime">Provides a snapshot of timing values.</param>
95 protected override void Draw(GameTime gameTime)
97 GraphicsDevice.Clear(Color.White);
101 player.Draw(spriteBatch);